/**
 * File: NodeStatusRemoveFlag.java
 * Created by: mhaimel
 * Created on: Mar 25, 2010
 * CVS:  $Id: NodeStatusRemoveFlag.java 1.0 Mar 25, 2010 11:02:41 AM mhaimel Exp $
 */
package uk.ac.ebi.curtain.model.graph.curtain.filter;

import uk.ac.ebi.curtain.model.graph.Node;
import uk.ac.ebi.curtain.model.graph.GraphAccess.TouchEach;
import uk.ac.ebi.curtain.utils.BitUtil;

/**
 * @author mhaimel
 * @param <N>
 * @param <A>
 *
 */
public class NodeStatusRemoveFlag<N, A> implements TouchEach<Node<N, A>> {
	private final int flag;
	public NodeStatusRemoveFlag(int flag) {
		this.flag = flag;
	}
	@Override
	public void touch(Node<N, A> node) {
		while(true){
			int val = node.getStatus().get();
			int up = BitUtil.removeFlag(val, this.flag);
			if(node.getStatus().compareAndSet(val, up)){
				break;
			}
		}
	}
}
